#include "rtda/heap/object.h"
#include "rtda/heap/class.h"
#include "rtda/heap/slots.h"

namespace jvm {
namespace heap {

Object::Object(std::weak_ptr<Class> pClass) 
    : m_pClass(pClass),
      m_pFields(new Slots(pClass->getInstanceSlotCount())) {}

std::weak_ptr<Class> Object::getClass() const { return m_pClass; }
std::weak_ptr<Slots> Object::getFields() const { return m_pFields; }

bool Object::isInstanceOf(std::weak_ptr<Class> pClass) const {
    return pClass->isAssignableFrom(m_pClass);
}

} // namespace heap
} // namespace jvm